package com.example.chooseconstellation;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnFocusChangeListener {
    private TextView tv_info,tv_choose;
    private ImageButton ib_img1,ib_img2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ib_img1=(ImageButton) findViewById(R.id.ib_img1);
        ib_img2=(ImageButton) findViewById(R.id.ib_img2);
        tv_info=(TextView) findViewById(R.id.tv_info);
        tv_info.setText("请选择下列中您喜欢的星座");
        tv_choose=(TextView) findViewById(R.id.tb_choose);
        ib_img1.setOnFocusChangeListener(this);
        ib_img2.setOnFocusChangeListener(this);
    }

    @Override
    public void onFocusChange(View view, boolean hasFocus) {
        switch(view.getId()) {
            case R.id.ib_img1:
            tv_choose.setText("您选中了狮子座");
                break;
            case R.id.ib_img2:
            tv_choose.setText("您选中了双子座");
                break;
        }
    }
}
